package com.zhoust.design.strategy.context;

import com.zhoust.design.strategy.intf.PayStrategy;
import com.zhoust.design.strategy.stategy.AliPay;
import com.zhoust.design.strategy.stategy.WeiCharPay;
import lombok.Data;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zhoushengtao
 * @version v1.0
 * @date 2021/11/1 20:52
 * @desc 支付策略环境
 */
@Component
@Slf4j
@Setter
public class PayStrategyContext {

    private  ConcurrentHashMap<String, PayStrategy> strategyMap ;

    public PayStrategy getPayStrategy(String payCode){
        if(!StringUtils.hasText(payCode)){
            log.error("未获取到对应的payCode：{}",payCode);
            return null;
        }
        return strategyMap.get(payCode);
    }
}
